import { axiosInstance } from 'src/boot/axios'
import CommonConfig from 'src/assets/js/config'

const bmsUrl = CommonConfig.bmsUrl + '/v1'

// /**
//  * 获取菜单
//  * search 搜索值
//  * **/
// export function getCompany (params) {
//   const newUrl = baseUrl + '/back/quicksearch/companyname'
//
//   return axiosInstance.get(newUrl, { params }).then((res) => {
//     return Promise.resolve(res)
//   })
// }
//
// /**
//  * 获取企业菜单id
//  * name 企业名称
//  * terminalType 终端类型
//  * **/
// export function getCompanyMenu (params) {
//   const newUrl = baseUrl + '/back/companyMenu/getList'
//
//   return axiosInstance.get(newUrl, { params }).then((res) => {
//     return Promise.resolve(res)
//   })
// }
//
// /**
//  * 保存企业菜单id
//  * name 企业名称
//  * ids
//  * **/
// export function saveCompanySatus (params) {
//   const newUrl = baseUrl + '/back/companyMenu/save'
//
//   return axiosInstance.post(newUrl, params).then((res) => {
//     return Promise.resolve(res)
//   })
// }
/**
 * 获取企业菜单
 * clientType 客户端类型 pc or mobile
 * **/
export function getCompanyMenuId (params, companyId) {
  const newUrl = `${bmsUrl}/companies/${companyId}/view_privileges`

  return axiosInstance.get(newUrl, { params }).then((res) => {
    return Promise.resolve(res)
  })
}

/**
 * 保存企业菜单
 * clientType 客户端类型 pc or mobile
 * privileges 菜单id列表
 * **/
export function saveCompanyMenuId (params, companyId) {
  const newUrl = `${bmsUrl}/companies/${companyId}/view_privileges`

  return axiosInstance.put(newUrl, params).then((res) => {
    return Promise.resolve(res)
  })
}

/**
 * 保存租户业务权限
 * clientType 客户端类型 pc or mobile
 * privileges 业务权限id列表
 * **/
export function saveCompanyBusinessIds (clientType, privileges, companyId) {
  const newUrl = `${bmsUrl}/companies/${companyId}/biz_privileges`

  let reqData = {
    clientType: clientType,
    privileges: privileges
  }

  return axiosInstance.put(newUrl, reqData).then((res) => {
    return Promise.resolve(res)
  })
}
